package com.itnoob.service;

import com.itnoob.adapter.PayAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author zhoujun
 * @date 2025/3/17 21:23
 */
@Service
public class PayForThirdServiceImpl implements PayService {


    @Autowired
    List<PayAdapter> payAdapters;

    @Override
    public String payForThird(String id, BigDecimal amount, String type) {

        for (PayAdapter payAdapter : payAdapters) {
            if (payAdapter.support(type)){
                return payAdapter.pay(id,amount,type);
            }
        }
        return "不支持该支付方式";
    }
}
